<?php
namespace cmFly\controller\system\config\handlers;
//If sfYaml not loaded!
if(!class_exists('/sfYaml')) {
    require(__DIR__.'/sfYaml/sfYaml.php');
}
class yaml extends \cmFly\controller\system\config\handler_base {
    protected function load($config_name) {
	return \sfYaml::load($this->dir.$config_name.$this->get_file_ext());
    }
    public function save(\cmFly\controller\system\config\instance $instance) {
	$content=\sfYaml::dump($instance->getArrayCopy());
	$fp=fopen($instance->get_config_name(),'a+');
	flock($fp,\LOCK_EX);
	ftruncate($fp,0);
	$ret=fwrite($fp, $content);
	fclose($fp);
	return $ret;
    }
    public function get_file_ext() {
	return '.yml';
    }
}
